﻿using Sustainalytics.ClientDW.DataAccessLayer;
using Sustainalytics.ClientDW.Entities;
using Sustainalytics.Utils;
using System;
using System.Collections.Generic;

namespace Sustainalytics.GCCS
{
    public class GCOverallCompanySummaryManager : IGCOverallCompanySummaryManager
    {
        private readonly IClientDWGlobalCompactRepository _gccRepo;


        public GCOverallCompanySummaryManager(IClientDWGlobalCompactRepository gccRepo)
        {
            _gccRepo = gccRepo;
        }

        public GCOverallCompanySummary GetByCompany(List<int> universeIds, Guid companyId, GCAssessment? overallAssessment, bool intersectUniverse=true)
        {
            string args = LogArgument.GetString(new { overallAssessment = overallAssessment });

            try
            {
                GCCEventSource.Log.GCOverallCompanySummary_GetByCompany(companyId, args);

                GCOverallCompanySummary data = _gccRepo.GetGCOverallCompanySummaryByCompany(universeIds, companyId, overallAssessment);

                if (data != null)
                {
                    GCCEventSource.Log.GCOverallCompanySummary_GetByCompany_Success(companyId, args);
                }                

                return data;
            }
            catch (Exception ex)
            {
                GCCEventSource.Log.GCOverallCompanySummary_GetByCompany_Error(companyId, args, ex);
                throw;
            }
        }
    }
}
